package com.zm.demo.shoppingmall.gateway.controller;

import com.zm.demo.shoppingmall.common.response.ShoppintMallResponse;
import com.zm.demo.shoppingmall.gateway.service.StorageManager;
import com.zm.demo.shoppingmall.storage.model.TStorage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @desc:
 * @author: z01140
 * @date: 2021/5/25 10:20
 */

@RestController
@RequestMapping("/storage")
public class StorageController {

    @Autowired
    private StorageManager storageManager;

    @PostMapping("/addStorage")
    public ShoppintMallResponse addStorage(@RequestBody TStorage storage){

        int r =  storageManager.addStorage(storage);
        return ShoppintMallResponse.response(1,"新增库存成功", r);
    }

    @GetMapping("/getStorageById")
    public ShoppintMallResponse getStorageById(Integer storageId){
        TStorage storage =  storageManager.getStorageById(storageId);
        return ShoppintMallResponse.response(1,"查询库存成功", storage);
    }
}
